home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2001 May / SGI Freeware 2001 May - Disc 1.iso / dist / fw_qt.idb / usr / freeware / include / qscrollview.h.z / qscrollview.h
Encoding:
C/C++ Source or Header  |  2001-04-12  |  7.6 KB  |  226 lines

  1. /****************************************************************************
  2. ** $Id: qt/src/widgets/qscrollview.h   2.3.0   edited 2001-02-08 $
  3. **
  4. ** Definition of QScrollView class
  5. **
  6. ** Created : 970523
  7. **
  8. ** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
  9. **
  10. ** This file is part of the widgets module of the Qt GUI Toolkit.
  11. **
  12. ** This file may be distributed under the terms of the Q Public License
  13. ** as defined by Trolltech AS of Norway and appearing in the file
  14. ** LICENSE.QPL included in the packaging of this file.
  15. **
  16. ** This file may be distributed and/or modified under the terms of the
  17. ** GNU General Public License version 2 as published by the Free Software
  18. ** Foundation and appearing in the file LICENSE.GPL included in the
  19. ** packaging of this file.
  20. **
  21. ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
  22. ** licenses may use this file in accordance with the Qt Commercial License
  23. ** Agreement provided with the Software.
  24. **
  25. ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  26. ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  27. **
  28. ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
  29. **   information about Qt Commercial License Agreements.
  30. ** See http://www.trolltech.com/qpl/ for QPL licensing information.
  31. ** See http://www.trolltech.com/gpl/ for GPL licensing information.
  32. **
  33. ** Contact info@trolltech.com if any conditions of this licensing are
  34. ** not clear to you.
  35. **
  36. **********************************************************************/
  37. #ifndef QSCROLLVIEW_H
  38. #define QSCROLLVIEW_H
  39.  
  40. #ifndef QT_H
  41. #include "qframe.h"
  42. #include "qscrollbar.h"
  43. #endif // QT_H
  44.  
  45. #ifndef QT_NO_SCROLLVIEW
  46.  
  47. struct QScrollViewData;
  48.  
  49. class Q_EXPORT QScrollView : public QFrame
  50. {
  51.     Q_OBJECT
  52.     Q_ENUMS( ResizePolicy ScrollBarMode )
  53.     Q_PROPERTY( ResizePolicy resizePolicy READ resizePolicy WRITE setResizePolicy )
  54.     Q_PROPERTY( ScrollBarMode vScrollBarMode READ vScrollBarMode WRITE setVScrollBarMode )
  55.     Q_PROPERTY( ScrollBarMode hScrollBarMode READ hScrollBarMode WRITE setHScrollBarMode )
  56.     Q_PROPERTY( int visibleWidth READ visibleWidth )
  57.     Q_PROPERTY( int visibleHeight READ visibleHeight )
  58.     Q_PROPERTY( int contentsWidth READ contentsWidth )
  59.     Q_PROPERTY( int contentsHeight READ contentsHeight )
  60.     Q_PROPERTY( int contentsX READ contentsX )
  61.     Q_PROPERTY( int contentsY READ contentsY )
  62. #ifndef QT_NO_DRAGANDDROP
  63.     Q_PROPERTY( bool dragAutoScroll READ dragAutoScroll WRITE setDragAutoScroll )
  64. #endif
  65.  
  66. public:
  67.     QScrollView(QWidget *parent=0, const char *name=0, WFlags f=0);
  68.     ~QScrollView();
  69.  
  70.     enum ResizePolicy { Default, Manual, AutoOne, AutoOneFit  };
  71.     virtual void setResizePolicy( ResizePolicy );
  72.     ResizePolicy resizePolicy() const;
  73.  
  74.     void styleChange(QStyle&);
  75.     void removeChild(QWidget* child);
  76.     virtual void addChild( QWidget* child, int x=0, int y=0 );
  77.     virtual void moveChild( QWidget* child, int x, int y );
  78.     int childX(QWidget* child);
  79.     int childY(QWidget* child);
  80.     bool childIsVisible(QWidget* child);
  81.     void showChild(QWidget* child, bool yes=TRUE);
  82.  
  83.     enum ScrollBarMode { Auto, AlwaysOff, AlwaysOn };
  84.  
  85.     ScrollBarMode vScrollBarMode() const;
  86.     virtual void  setVScrollBarMode( ScrollBarMode );
  87.  
  88.     ScrollBarMode hScrollBarMode() const;
  89.     virtual void  setHScrollBarMode( ScrollBarMode );
  90.  
  91.     QWidget*     cornerWidget() const;
  92.     virtual void setCornerWidget(QWidget*);
  93.  
  94.     QScrollBar*  horizontalScrollBar() const;
  95.     QScrollBar*  verticalScrollBar() const;
  96.     QWidget*     viewport() const;
  97.     QWidget*     clipper() const;
  98.  
  99.     int        visibleWidth() const;
  100.     int        visibleHeight() const;
  101.  
  102.     int        contentsWidth() const;
  103.     int        contentsHeight() const;
  104.     int        contentsX() const;
  105.     int        contentsY() const;
  106.  
  107.     void    resize( int w, int h );
  108.     void    resize( const QSize& );
  109.     void    show();
  110.  
  111.     void    updateContents( int x, int y, int w, int h );
  112.     void    updateContents( const QRect& r );
  113.     void    repaintContents( int x, int y, int w, int h, bool erase=TRUE );
  114.     void    repaintContents( const QRect& r, bool erase=TRUE );
  115. //### make this const in 3.0
  116.     void    contentsToViewport(int x, int y, int& vx, int& vy);
  117. //### make this const in 3.0
  118.     void    viewportToContents(int vx, int vy, int& x, int& y);
  119.     QPoint    contentsToViewport(const QPoint&);
  120.     QPoint    viewportToContents(const QPoint&);
  121.     void    enableClipper(bool y);
  122.  
  123.     void     setStaticBackground(bool y);
  124.     bool     hasStaticBackground() const;
  125.  
  126.     QSize    viewportSize( int, int ) const;
  127.     QSizePolicy sizePolicy() const;
  128.     QSize    sizeHint() const;
  129.     QSize    minimumSizeHint() const;
  130.  
  131.     void    removeChild(QObject* child);
  132.  
  133. #ifndef QT_NO_DRAGANDDROP
  134.     void    setDragAutoScroll( bool b ); // #### virtual in 3.0
  135.     bool    dragAutoScroll() const;
  136. #endif
  137.  
  138. signals:
  139.     void    contentsMoving(int x, int y);
  140.  
  141. public slots:
  142.     virtual void resizeContents( int w, int h );
  143.     void    scrollBy( int dx, int dy );
  144.     virtual void        setContentsPos( int x, int y );
  145.     void    ensureVisible(int x, int y);
  146.     void    ensureVisible(int x, int y, int xmargin, int ymargin);
  147.     void    center(int x, int y);
  148.     void    center(int x, int y, float xmargin, float ymargin);
  149.  
  150.     void    updateScrollBars();
  151.     void    setEnabled( bool enable );
  152.  
  153. protected:
  154.     void    resizeEvent(QResizeEvent*);
  155.     void     wheelEvent( QWheelEvent * );
  156.     bool    eventFilter( QObject *, QEvent *e );
  157.  
  158.     virtual void contentsMousePressEvent( QMouseEvent* );
  159.     virtual void contentsMouseReleaseEvent( QMouseEvent* );
  160.     virtual void contentsMouseDoubleClickEvent( QMouseEvent* );
  161.     virtual void contentsMouseMoveEvent( QMouseEvent* );
  162. #ifndef QT_NO_DRAGANDDROP
  163.     virtual void contentsDragEnterEvent( QDragEnterEvent * );
  164.     virtual void contentsDragMoveEvent( QDragMoveEvent * );
  165.     virtual void contentsDragLeaveEvent( QDragLeaveEvent * );
  166.     virtual void contentsDropEvent( QDropEvent * );
  167. #endif
  168.     virtual void contentsWheelEvent( QWheelEvent * );
  169.  
  170.     virtual void viewportPaintEvent( QPaintEvent* );
  171.     virtual void viewportResizeEvent( QResizeEvent* );
  172.     virtual void viewportMousePressEvent( QMouseEvent* );
  173.     virtual void viewportMouseReleaseEvent( QMouseEvent* );
  174.     virtual void viewportMouseDoubleClickEvent( QMouseEvent* );
  175.     virtual void viewportMouseMoveEvent( QMouseEvent* );
  176. #ifndef QT_NO_DRAGANDDROP
  177.     virtual void viewportDragEnterEvent( QDragEnterEvent * );
  178.     virtual void viewportDragMoveEvent( QDragMoveEvent * );
  179.     virtual void viewportDragLeaveEvent( QDragLeaveEvent * );
  180.     virtual void viewportDropEvent( QDropEvent * );
  181. #endif
  182.     virtual void viewportWheelEvent( QWheelEvent * );
  183.  
  184.     virtual void drawContentsOffset(QPainter*, int ox, int oy,
  185.             int cx, int cy, int cw, int ch);
  186.     virtual void drawContents(QPainter*, int cx, int cy, int cw, int ch);
  187.     void    frameChanged();
  188.  
  189.     virtual void setMargins(int left, int top, int right, int bottom);
  190.     int leftMargin() const;
  191.     int topMargin() const;
  192.     int rightMargin() const;
  193.     int bottomMargin() const;
  194.  
  195.     bool focusNextPrevChild( bool next );
  196.  
  197.     virtual void setHBarGeometry(QScrollBar& hbar, int x, int y, int w, int h);
  198.     virtual void setVBarGeometry(QScrollBar& vbar, int x, int y, int w, int h);
  199.  
  200. private:
  201.     virtual void drawContents( QPainter* );
  202.     void moveContents(int x, int y);
  203.  
  204.     QScrollViewData* d;
  205.  
  206. private slots:
  207.     void hslide(int);
  208.     void vslide(int);
  209. #ifndef QT_NO_DRAGANDDROP
  210.     void doDragAutoScroll();
  211.     void startDragAutoScroll();
  212.     void stopDragAutoScroll();
  213. #endif
  214.  
  215. private:    // Disabled copy constructor and operator=
  216. #if defined(Q_DISABLE_COPY)
  217.     QScrollView( const QScrollView & );
  218.     QScrollView &operator=( const QScrollView & );
  219. #endif
  220.     void changeFrameRect(const QRect&);
  221. };
  222.  
  223. #endif // QT_NO_SCROLLVIEW
  224.  
  225. #endif // QSCROLLVIEW_H
  226.